﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Xml;


namespace SitecoreTranslation.Integration.Settings
{
	
	public class TranslationSettings 
	{
		public const String TranslationSettingsNode = "TranslationSettings";
		public const String Source = "SourceLanguage";
		public const String Target = "TargetLanguage";

		public XmlElement Serialize(XmlDocument document)
		{
			XmlElement result = document.CreateElement(TranslationSettingsNode);

			result.SetAttribute(Source, SourceLanguage);
			result.SetAttribute(Target, TargetLanguage);

			return result;
		}

		public void Deserialize(XmlDocument document)
		{
			XmlElement settings = (XmlElement)document.SelectSingleNode(string.Format("/{0}/{1}/{2}", BaseAction.RootName, BaseAction.ItemName, TranslationSettingsNode));

			SourceLanguage = settings.GetAttribute(Source);
			TargetLanguage = settings.GetAttribute(Target);

		
		}
	
		public string SourceLanguage { get; set; }
		
		public string TargetLanguage { get; set; }
	}
}
